package com.health.healthSys.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import com.health.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.health.healthSys.domain.HealthRole;
import com.health.healthSys.mapper.HealthRoleMapper;
import com.health.healthSys.domain.HealthRole;
import com.health.healthSys.service.IHealthRoleService;

/**
 * 角色管理Service业务层处理
 *
 * @author maple
 * @date 2025-02-28
 */
@Service
public class HealthRoleServiceImpl implements IHealthRoleService {
    @Autowired
    private HealthRoleMapper healthRoleMapper;

    /**
     * 查询角色管理
     *
     * @param id 角色管理主键
     * @return 角色管理
     */
    @Override
    public HealthRole selectHealthRoleById(Long id) {
        return healthRoleMapper.selectHealthRoleById(id);
    }

    /**
     * 查询角色管理列表
     *
     * @param healthRole 角色管理
     * @return 角色管理
     */
    @Override
    public List<HealthRole> selectHealthRoleList(HealthRole healthRole) {
        return healthRoleMapper.selectHealthRoleList(healthRole);
    }

    /**
     * 新增角色管理
     *
     * @param healthRole 角色管理
     * @return 结果
     */
    @Transactional
    @Override
    public int insertHealthRole(HealthRole healthRole) {
        int rows = healthRoleMapper.insertHealthRole(healthRole);
        insertHealthRole(healthRole);
        return rows;
    }

    /**
     * 修改角色管理
     *
     * @param healthRole 角色管理
     * @return 结果
     */
    @Transactional
    @Override
    public int updateHealthRole(HealthRole healthRole) {
        healthRoleMapper.deleteHealthRoleById(healthRole.getId());
        insertHealthRole(healthRole);
        return healthRoleMapper.updateHealthRole(healthRole);
    }

    /**
     * 批量删除角色管理
     *
     * @param ids 需要删除的角色管理主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteHealthRoleByIds(Long[] ids) {
        healthRoleMapper.deleteHealthRoleByIds(ids);
        return healthRoleMapper.deleteHealthRoleByIds(ids);
    }

    /**
     * 删除角色管理信息
     *
     * @param id 角色管理主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteHealthRoleById(Long id) {
        healthRoleMapper.deleteHealthRoleById(id);
        return healthRoleMapper.deleteHealthRoleById(id);
    }

}
